package cn.controller;

import cn.pojo.Page;
import cn.pojo.Student;
import cn.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class StudentController {
    @Autowired
    private StudentService service;


    @RequestMapping("findByPage")
    public String findByPage(String name, Integer pageNum, Model model){
        if (pageNum == null) {
            pageNum = 1;
        }
        Student student = new Student();
        if (!("null").equals(name)&&!("").equals(name)) {
            model.addAttribute("name",name);
            student.setName(name);
        }

        Page page = service.findByPage(student,"findByPage", pageNum);
        model.addAttribute("page",page);
        return "students";

    }
}
